<template>
	<view>
		<view class="item">
			<text>省</text>
			<vvSelect v-model="formData['province']" placeholder="请选择" style="margin-left: 5px;"
				@change="provinceChangeHandle"
			 :list="provinceList" valueKey="id" label="label" ></vvSelect>
		</view>
		<view class="item">
			<text>市</text>
			<vvSelect v-model="formData['City']" placeholder="请选择" style="margin-left: 5px;"
				:list="provinceList" valueKey="id" label="label" 
				:disabled="!!!formData['province']"></vvSelect>
		</view>
	</view>
</template>

<script>
	import vvSelect from '@/components/vv-select/vv-select'
	import { ajax, getUserInfo} from '@/common/common.js'
	import {bpmUrl} from "@/common/config.js"
	export default {
		components:{
			vvSelect
		},
		props: {
			formData: Object
		},
		data() {
			return {
				provinceList: []
			};
		},
		methods: {
			provinceChangeHandle() {
				if(this.formData['province']) {
					this.loadCity()
				}
			},
			loadProvince() {
				let user = getUserInfo()
				let searchField = {
					paramasMap: {},
					headersMap: {
						sysid: "bpm",
						syspwd: "pass",
						userid: user.bpmUid
					},
					url: bpmUrl + '/rest/appform/CRMVR/R_CRMVR_B164'
				}
				ajax({
					url:'/bpm/get',
					method: 'POST',
					data: searchField,
					success:res => {
						console.log("省：", res)
					}
				})
			},
			loadCity() {
				let user = getUserInfo()
				let searchField = {
					paramasMap: {
						province: this.formData['province']
					},
					headersMap: {
						sysid: "bpm",
						syspwd: "pass",
						userid: user.bpmUid
					},
					url: bpmUrl + '/rest/appform/CRMVR/R_CRMVR_B165'
				}
				ajax({
					url:'/bpm/get',
					method: 'POST',
					data: searchField,
					success:res => {
						formData.Department = res.data.data
					}
				})
			},
		},
		mounted() {
			this.loadProvince()
		}
	}
</script>

<style scoped>
.item{
	margin-left: 5px;
}
</style>
